<template>
  <div class="dialog-container">
    <el-dialog
      :title="dialogType==='add'?'添加仪器仪表':dialogType === 'detail'?'仪器仪表详情':'修改仪器仪表'"
      :visible="dialogVisible"
      @open="initData"
      @close="closeDialog"
    >
      <el-form
        ref="form"
        :model="dataForm"
        class="dialog-form"
        :rules="rules"
        label-width="130px"
        size="mini"
        :disabled="dialogType === 'detail'"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="品牌" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="型号" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="类型" prop="factorType">
              <el-select>
                <el-option />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="监测因子" prop="factorType">
              <el-select>
                <el-option />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出厂编号" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产商" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="集成商" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产许可证编号" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仪器仪表图片" prop="factorType">
              <UploadImage
                @setUrl="setInstrumentImage"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仪器仪表资质图片" prop="factorType">
              <UploadImage
                @setUrl="setCertificationImage"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="环保产品认证编号" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="协议类型" prop="factorType">
              <el-input />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button :loading="saveLoading" size="mini" type="primary" @click="handleSave">保存</el-button>
        <el-button size="mini" @click="closeDialog">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import UploadImage from '@/components/UploadImage/index'
export default {
  name: 'AddInstrumentDialog',
  components: {
    UploadImage
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    dialogType: {
      type: String,
      default: 'detail'
    },
    obj: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      dataForm: {},
      rules: {},
      saveLoading: true
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 打开
    initData() {
      if (this.obj) {
        const obj = JSON.props(JSON.stringify(this.obj))
        this.dataForm = obj
      }
    },
    // 关闭
    closeDialog() {
      this.$emit('closeDialog')
    },
    // 上传仪器仪表图片
    setInstrumentImage() {},
    // 上传仪器仪表资质图片
    setCertificationImage() {},
    // 保存
    handleSave() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.saveLoading = true
        }
      })
    },
    // 刷新
    flushPage() {
      this.$emit('flushPage')
    }
  }
}
</script>

<style lang='scss' scoped>
</style>
